// component/articleList/articlelist.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    itemData:{
      type:Object,
      value:{},
      observer:function(newval){
        //处理点赞转发等数据
        if (JSON.stringify(newval) !== '{}') {
          //点赞评论收藏
          let count = {
            praises:newval.praises,
            commentCounts:newval.commentCounts,
            stores:newval.stores,
            articleId:newval._id
          }
          //处理发布者信息
          this.setData({
            count:count,
            articleId:newval._id,
            time:newval.publicTime,
            userInfo:newval.articleWithuser[0]
          })
        }
      }
    }
  },
  
  /**
   * 组件的初始数据
   */
  data: {
    count:{},
    articleId:'',
    userInfo:{},
    time:''
  },

  
  /**
   * 组件的方法列表
   */
  
  methods: {
  //跳转到阅读页面 
  toReading(){
    wx.navigateTo({
      url:`../reading/reading?id=${this.data.articleId}`,
    })
  },

  upDate(data){
    wx.cloud.callFunction({
      name:'changeArticle',
      data:data,
      success:(res)=>{
        console.log(res);
      }
    })
  },
  }
})
